import { PagePathEnum, PageNameEnum } from '@/enums/PageEnums'

const Login = () => import('../../views/login/login.vue')
const UserInfo = () => import('../../views/user_info/UserInfo.vue')
const SaleInfo = () => import('../../views/sale_info/SaleInfo.vue')
const Listing = () => import('../../views/listing/Listing.vue')
const GoodList = () => import('../../views/good_list/GoodList.vue')
const NoPermission = () => import('../../views/no_permission/NoPermission.vue')
const NotFound = () => import('../../views/error/404.vue')
const Delivery = () => import('../../views/delivery/delivery.vue')
const HomeLayout = () => import('../../layout/HomeLayout.vue')


export const routes = [
  {
    name: PageNameEnum.LOGIN,
    path: PagePathEnum.LOGIN,
    component: Login,
    meta: {
      title: '登录'
    }
  },
  {
    name: 'home',
    component: HomeLayout,
    path: PagePathEnum.HOME,
    redirect: {name: PageNameEnum.LOGIN},
    children: [
      {
        name: PageNameEnum.GOOD_LIST,
        path: PagePathEnum.GOOD_LIST,
        component: GoodList,
        meta: {
          title: '商品列表',
          roles: ['代销处用户']
        }
      },
      {
        name: PageNameEnum.LISTING,
        path: PagePathEnum.LISTING,
        component: Listing,
        meta: {
          title: '清单',
          roles: ['公司销售主管']
        }
      },
      {
        name: PageNameEnum.SALE_INFO,
        path: PagePathEnum.SALE_INFO,
        component: SaleInfo,
        meta: {
          title: '销售信息',
          roles: ['公司财务主管']
        }
      },
      {
        name: PageNameEnum.USER_INFO,
        path: PagePathEnum.USER_INFO,
        component: UserInfo,
        meta: {
          title: '用户信息',
          roles: ['公司营销主管']
        }
      },
    
      {
        name: PageNameEnum.DELIVERY,
        path: PagePathEnum.DELIVERY,
        component: Delivery,
        meta: {
          title: '送货详情',
          roles: ['公司送货主管']
        }
      },
    ]
  },
  {
    name: PageNameEnum.ERROR,
    path: PagePathEnum.ERROR,
    component: NotFound,
    meta: {
      title: '错误页面',
    },
    children: [
      {
        name: PageNameEnum.NOT_FOUND,
        path: PagePathEnum.NOT_FOUND,
        component: NotFound
      }
    ]
  },
  {
    name: PageNameEnum.NO_PERMISSION,
    path: PagePathEnum.NO_PERMISSION,
    component: NoPermission,
    meta: {
      title: '无权限访问',
    }
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: { name: PageNameEnum.NOT_FOUND }
  },
]